package com.hsc.yalebao.tabMine;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.gson.Gson;
import com.hsc.yalebao.base.ActivityStack;
import com.hsc.yalebao.base.BaseActivity;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.base.MainActivity;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.model.ChangeMobileBean;
import com.hsc.yalebao.model.GetVeriyCodeBean;
import com.hsc.yalebao.model.UserBaseBean;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.hsc.yalebao.weight.MyDialog1;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.HashMap;
import java.util.Timer;
import java.util.TimerTask;
import okhttp3.Call;

public class BoundPhoneActivity extends BaseActivity
{
  private String TAG = "BoundPhoneActivity";
  private Context context;
  private EditText edit_user_phone_no;
  private EditText edit_user_veriy_code;
  private Button get_veriycode;
  private Handler handler = new Handler()
  {
    public void handleMessage(Message paramAnonymousMessage)
    {
      super.handleMessage(paramAnonymousMessage);
      switch (paramAnonymousMessage.what)
      {
      default:
        return;
      case 0:
        BoundPhoneActivity.this.isPause = false;
        int i = paramAnonymousMessage.arg1;
        BoundPhoneActivity.this.get_veriycode.setText(i + "s");
        BoundPhoneActivity.this.get_veriycode.setBackgroundResource(2130837970);
        BoundPhoneActivity.this.get_veriycode.setEnabled(false);
        return;
      case 1:
      }
      BoundPhoneActivity.this.isPause = true;
      BoundPhoneActivity.this.timerRecord = 120;
      BoundPhoneActivity.this.get_veriycode.setText("重新获取");
      BoundPhoneActivity.this.get_veriycode.setBackgroundResource(2130837969);
      BoundPhoneActivity.this.get_veriycode.setEnabled(true);
    }
  };
  private ImageView img_commit;
  private ImageView img_sure;
  private boolean isPause = true;
  private ImageView iv_title_right;
  private LinearLayout ll_weibangding;
  private LinearLayout ll_yanzhengma;
  private LinearLayout ll_yijingbangding;
  private int memberid;
  private MyDialog1 myDialog1;
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      case 2131099704:
      default:
        return;
      case 2131099699:
      case 2131099756:
        BoundPhoneActivity.this.closeWindowSoftInput(BoundPhoneActivity.this.edit_user_phone_no);
        BoundPhoneActivity.this.closeWindowSoftInput(BoundPhoneActivity.this.edit_user_veriy_code);
        CustomApplication.app.finishActivity(BoundPhoneActivity.this);
        return;
      case 2131099755:
        String str = BoundPhoneActivity.this.edit_user_phone_no.getText().toString().trim();
        if (str.isEmpty())
          BoundPhoneActivity.this.ShowDialog1("手机号不能为空");
        if (!UiUtil.isMobileNO(str))
        {
          BoundPhoneActivity.this.ShowDialog1("请检查您的手机号");
          return;
        }
        BoundPhoneActivity.this.Daojishi();
        BoundPhoneActivity.this.getveriycode(str);
        BoundPhoneActivity.this.ShowDialog1("请稍等");
        return;
      case 2131099742:
      }
      BoundPhoneActivity.this.checkoutdata();
    }
  };
  private TextWatcher textWatcher = new TextWatcher()
  {
    public void afterTextChanged(Editable paramAnonymousEditable)
    {
    }

    public void beforeTextChanged(CharSequence paramAnonymousCharSequence, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
    {
    }

    public void onTextChanged(CharSequence paramAnonymousCharSequence, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
    {
      if (BoundPhoneActivity.this.edit_user_phone_no.getText().toString().equals(""))
      {
        BoundPhoneActivity.this.get_veriycode.setBackgroundResource(2130837970);
        BoundPhoneActivity.this.get_veriycode.setEnabled(false);
      }
      if (BoundPhoneActivity.this.edit_user_phone_no.getText().toString().length() == 11)
      {
        BoundPhoneActivity.this.get_veriycode.setBackgroundResource(2130837554);
        BoundPhoneActivity.this.get_veriycode.setEnabled(true);
      }
    }
  };
  private Timer timer = new Timer();
  private int timerRecord = 120;
  private TextView tv_phone;
  private View view_title;

  private void ChangeMobile(final String paramString1, String paramString2)
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("mobile", paramString1);
    localHashMap.put("code", paramString2);
    localHashMap.put("memberid", this.memberid);
    LogUtils.d(this.TAG, "URL:" + AppConstants.URL_GET_CHANGEMOBILE);
    RequestNet.get(this.context, AppConstants.URL_GET_CHANGEMOBILE, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        LogUtils.e(BoundPhoneActivity.this.TAG, "请求失败,:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        LogUtils.d(BoundPhoneActivity.this.TAG, "changeMobileBean数据" + paramAnonymousString);
        if (UiUtil.IsValueEmpty(paramAnonymousString))
          LogUtils.d(BoundPhoneActivity.this.TAG, "changeMobileBean:" + paramAnonymousString);
        ChangeMobileBean localChangeMobileBean;
        do
        {
          return;
          Gson localGson = new Gson();
          try
          {
            localChangeMobileBean = (ChangeMobileBean)localGson.fromJson(paramAnonymousString, ChangeMobileBean.class);
            if (localChangeMobileBean == null)
            {
              LogUtils.e(BoundPhoneActivity.this.TAG, "getVeriyCodeBean == null，绑定失败");
              return;
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              localException.printStackTrace();
              localChangeMobileBean = null;
            }
            if (localChangeMobileBean.getFlag() == 0)
            {
              BoundPhoneActivity.this.myDialog1.setMessage(localChangeMobileBean.getMsg());
              BoundPhoneActivity.this.myDialog1.show();
              BoundPhoneActivity.this.myDialog1.btn_confirm.setOnClickListener(new View.OnClickListener()
              {
                public void onClick(View paramAnonymous2View)
                {
                  BoundPhoneActivity.this.edit_user_phone_no.setText("");
                  BoundPhoneActivity.this.edit_user_veriy_code.setText("");
                  BoundPhoneActivity.this.myDialog1.dismiss();
                }
              });
              return;
            }
            if (localChangeMobileBean.getFlag() == -2)
            {
              BoundPhoneActivity.this.showDownWireDialog();
              return;
            }
            if (localChangeMobileBean.getFlag() == -3)
            {
              BoundPhoneActivity.this.ShowFengjinDialog();
              return;
            }
            if (localChangeMobileBean.getFlag() == -4)
            {
              BoundPhoneActivity.activityStack.backToMain(MainActivity.class, BoundPhoneActivity.this.context);
              return;
            }
          }
        }
        while (localChangeMobileBean.getFlag() != 1);
        BoundPhoneActivity.this.myDialog1.setMessage(localChangeMobileBean.getMsg());
        BoundPhoneActivity.this.myDialog1.show();
        BoundPhoneActivity.this.myDialog1.btn_confirm.setOnClickListener(new View.OnClickListener()
        {
          public void onClick(View paramAnonymous2View)
          {
            BoundPhoneActivity.this.myDialog1.dismiss();
            BoundPhoneActivity.this.edit_user_veriy_code.setText("");
            BoundPhoneActivity.this.edit_user_phone_no.setText("");
            CustomApplication.app.userBaseBean.setPhone(this.val$number);
            CustomApplication.app.finishActivity(BoundPhoneActivity.this);
          }
        });
      }
    });
  }

  private void checkoutdata()
  {
    String str1 = this.edit_user_veriy_code.getText().toString();
    String str2 = this.edit_user_phone_no.getText().toString();
    if ("".equals(str2))
    {
      ShowDialog1("请输入您的手机号");
      return;
    }
    if (!UiUtil.isMobileNO(str2))
    {
      ShowDialog1("请检查您的手机号");
      return;
    }
    if ("".equals(str1))
    {
      ShowDialog1("请输入您的验证码");
      return;
    }
    if (str1.length() != 6)
    {
      ShowDialog1("请检查您的验证码");
      return;
    }
    ChangeMobile(str2, str1);
  }

  private void getveriycode(String paramString)
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("userphone", paramString);
    Log.d(this.TAG, "URL:" + AppConstants.URL_GET_VERIYCODE);
    setBoundBtnIsEnable(false);
    RequestNet.get(this.context, AppConstants.URL_GET_VERIYCODE, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        BoundPhoneActivity.this.setBoundBtnIsEnable(true);
        LogUtils.e(BoundPhoneActivity.this.TAG, "请求失败,:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        BoundPhoneActivity.this.setBoundBtnIsEnable(true);
        LogUtils.d(BoundPhoneActivity.this.TAG, "getVeriyCodeBean数据" + paramAnonymousString);
        if (UiUtil.IsValueEmpty(paramAnonymousString))
        {
          LogUtils.d(BoundPhoneActivity.this.TAG, "getVeriyCodeBean为空时:" + paramAnonymousString);
          return;
        }
        Gson localGson = new Gson();
        try
        {
          localGetVeriyCodeBean = (GetVeriyCodeBean)localGson.fromJson(paramAnonymousString, GetVeriyCodeBean.class);
          if (localGetVeriyCodeBean == null)
          {
            LogUtils.e(BoundPhoneActivity.this.TAG, "getVeriyCodeBean == null，获取失败");
            return;
          }
        }
        catch (Exception localException)
        {
          GetVeriyCodeBean localGetVeriyCodeBean;
          while (true)
          {
            localException.printStackTrace();
            localGetVeriyCodeBean = null;
          }
          if (localGetVeriyCodeBean.getFlag() == 0)
          {
            BoundPhoneActivity.this.ShowDialog1(localGetVeriyCodeBean.getMsg());
            return;
          }
          if (localGetVeriyCodeBean.getFlag() == -2)
          {
            BoundPhoneActivity.this.showDownWireDialog();
            return;
          }
          if (localGetVeriyCodeBean.getFlag() == -3)
          {
            BoundPhoneActivity.this.ShowFengjinDialog();
            return;
          }
          if (localGetVeriyCodeBean.getFlag() == -4)
          {
            BoundPhoneActivity.activityStack.backToMain(MainActivity.class, BoundPhoneActivity.this.context);
            return;
          }
          LogUtils.i(BoundPhoneActivity.this.TAG, "getVeriyCodeBean，获取成功");
        }
      }
    });
  }

  private void setBoundBtnIsEnable(boolean paramBoolean)
  {
    if (paramBoolean)
      this.img_commit.setBackgroundResource(2130837521);
    while (true)
    {
      this.img_commit.setEnabled(paramBoolean);
      return;
      this.img_commit.setBackgroundResource(2130838080);
    }
  }

  public void Daojishi()
  {
    if (this.isPause)
    {
      TimerTask local4 = new TimerTask()
      {
        public void run()
        {
          BoundPhoneActivity localBoundPhoneActivity = BoundPhoneActivity.this;
          localBoundPhoneActivity.timerRecord = (-1 + localBoundPhoneActivity.timerRecord);
          if (BoundPhoneActivity.this.timerRecord <= 0)
          {
            BoundPhoneActivity.this.timer.cancel();
            BoundPhoneActivity.this.timer = null;
            BoundPhoneActivity.this.handler.sendEmptyMessage(1);
            return;
          }
          Message localMessage = BoundPhoneActivity.this.handler.obtainMessage();
          localMessage.what = 0;
          localMessage.arg1 = BoundPhoneActivity.this.timerRecord;
          localMessage.sendToTarget();
        }
      };
      if (this.timer == null)
        this.timer = new Timer();
      this.timer.schedule(local4, 1000L, 1000L);
    }
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903046);
    CustomApplication.app.addActivity(this);
    this.context = this;
    setTitle(8, 0, 2130837809, "手机绑定", 0, 8, 8, 0, true);
    this.edit_user_phone_no = ((EditText)findViewById(2131099750));
    this.edit_user_phone_no.addTextChangedListener(this.textWatcher);
    this.ll_weibangding = ((LinearLayout)findViewById(2131099749));
    this.ll_yijingbangding = ((LinearLayout)findViewById(2131099751));
    this.ll_yanzhengma = ((LinearLayout)findViewById(2131099753));
    this.tv_phone = ((TextView)findViewById(2131099752));
    this.edit_user_veriy_code = ((EditText)findViewById(2131099754));
    this.img_commit = ((ImageView)findViewById(2131099742));
    this.img_sure = ((ImageView)findViewById(2131099756));
    this.img_commit.setOnClickListener(this.onClickListener);
    this.img_sure.setOnClickListener(this.onClickListener);
    this.get_veriycode = ((Button)findViewById(2131099755));
    this.get_veriycode.setOnClickListener(this.onClickListener);
    String str;
    if (CustomApplication.app.userBaseBean != null)
    {
      str = CustomApplication.app.userBaseBean.getPhone();
      this.memberid = CustomApplication.app.userBaseBean.getMemberid();
      if (str != null)
      {
        if (!str.isEmpty())
          break label333;
        this.ll_yijingbangding.setVisibility(8);
        this.img_sure.setVisibility(8);
        this.ll_yanzhengma.setVisibility(0);
        this.img_commit.setVisibility(0);
        this.ll_weibangding.setVisibility(0);
      }
    }
    while (true)
    {
      this.get_veriycode.setBackgroundResource(2130837970);
      this.get_veriycode.setEnabled(false);
      this.myDialog1 = new MyDialog1(this.context);
      return;
      label333: this.ll_yijingbangding.setVisibility(0);
      this.img_sure.setVisibility(0);
      this.ll_yanzhengma.setVisibility(8);
      this.img_commit.setVisibility(8);
      this.ll_weibangding.setVisibility(4);
      this.tv_phone.setText(str);
    }
  }

  protected void onDestroy()
  {
    super.onDestroy();
  }

  protected void onPause()
  {
    super.onPause();
    closeWindowSoftInput(this.edit_user_phone_no);
    closeWindowSoftInput(this.edit_user_veriy_code);
  }

  protected void onStart()
  {
    super.onStart();
  }

  @SuppressLint({"NewApi"})
  public void setTitle(int paramInt1, int paramInt2, int paramInt3, String paramString, int paramInt4, int paramInt5, int paramInt6, int paramInt7, boolean paramBoolean)
  {
    View localView = findViewById(2131099716);
    if (paramBoolean)
      localView.setVisibility(0);
    while (true)
    {
      ((TextView)localView.findViewById(2131099701)).setText(paramString);
      ((TextView)localView.findViewById(2131099700)).setVisibility(paramInt1);
      ImageView localImageView = (ImageView)localView.findViewById(2131099699);
      localImageView.setVisibility(paramInt2);
      localImageView.setOnClickListener(this.onClickListener);
      localImageView.setImageResource(paramInt3);
      TextView localTextView = (TextView)localView.findViewById(2131099702);
      localTextView.setVisibility(paramInt5);
      localTextView.setOnClickListener(this.onClickListener);
      this.iv_title_right = ((ImageView)localView.findViewById(2131099704));
      this.iv_title_right.setVisibility(paramInt6);
      this.iv_title_right.setOnClickListener(this.onClickListener);
      this.iv_title_right.setImageResource(paramInt7);
      return;
      localView.setVisibility(8);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.tabMine.BoundPhoneActivity
 * JD-Core Version:    0.6.2
 */